/* ----------------------------------------------------------------------- *
 *                                                                         *
 *    (C) Copyright 1996 by:  aiNet, Ales Krajnc, s.p.,                    *
 *										Trubarjeva 42, SI-3000 Celje,                *
 *										Europe, Slovenia                             *
 *     All Rights Reserved                                                 *
 *                                                                         *
 *     Subject: Simplified C code for single vector prediction.            *
 *     File:    C header file                                              *
 *                                                                         *
 * ----------------------------------------------------------------------- */

#include <windows.h>

/* Error constants */

#define AIERR_NO_ERROR           0
#define AIERR_PENALTY_ZERO      -1
#define AIERR_NO_IO_VARIABLES   -2
#define AIERR_PENALTY_TOO_SMALL -3
#define AIERR_EMPTY_ROW         -4
#define AIERR_EMPTY_COLUMN      -5
#define AIERR_EQUAL_COLUMN      -6
#define AIERR_CSV_OPEN          -7
#define AIERR_CSV_READ          -8
#define AIERR_MEMORY_ALLOCATION -9
#define AIERR_INVALID_POINTER   -10
#define AIERR_INVALID_INDEX     -11

/* Penalty coefficient constants */

#define PENALTY_STATIC   0
#define PENALTY_DYNAMIC  1
#define PENALTY_NEAREST  2

/* Normalization constants */

#define NORMALIZE_REGULAR   0
#define NORMALIZE_STATISTICAL  1

/* ----------------------------------------------------------------------- */

typedef float*  aiVector;

/* The aiModel Structure */

typedef struct aiTagModel{
	float **data;        /* model (vector of model vectors) */
	int nMV;             /* number of model vectors         */
	int nVar;            /* total number of variables       */
	int ni;              /* number of input variables       */
	int* discrete;			/* array of flags                  */
	aiVector n1;			/* normalization / denormalization */
	aiVector n2;			/* ...                             */
} aiModel;

extern const float MISSING;

/* ----------------------------------------------------------------------- */

#ifdef __cplusplus
extern "C" {
#endif

/* Functions defined in DLL */

int FAR PASCAL _export aiRegistration(const char* user, const char* code);
int FAR PASCAL _export aiGetVersion(void);

aiModel* FAR PASCAL _export aiCreateModel(int nMV, int nVar, int nInputVar);
aiModel* FAR PASCAL _export aiCreateModelFromCSVFile(const char* fileName);
int FAR PASCAL _export aiDeleteModel(aiModel* model);

int FAR PASCAL _export aiNormalize(aiModel* model, int method);
int FAR PASCAL _export aiDenormalize(aiModel* model);
int FAR PASCAL _export aiPrediction(aiModel* model, aiVector toPredict,
                           			float penalty, int method);
int FAR PASCAL _export aiGetNumberOfVariables(aiModel* model);
int FAR PASCAL _export aiGetNumberOfModelVectors(aiModel* model);
int FAR PASCAL _export aiGetNumberOfInputVariables(aiModel* model);
int FAR PASCAL _export aiSetDiscreteFlag(aiModel* model, int i, BOOL f);
int FAR PASCAL _export aiGetDiscreteFlag(aiModel* model, int i);
int FAR PASCAL _export aiSetVariable(aiModel* model, int mv, int v, float value);
float FAR PASCAL _export aiGetVariable(aiModel* model, int mv, int v);
int FAR PASCAL _export aiGetVariableVB(aiModel* model, int mv, int v, float* value);

DWORD FAR PASCAL _export aiGetCSVFileModelSize(const char* fileName);

/*
 * NOTE: Most of above functions return an integer. If the return value
 * is equal to AIERR_NO_ERROR than the function was succesful.
 * A negative value usually indicates an error.
 */
#ifdef __cplusplus
}
#endif


/* ----------------------------------------------------------------------- */
